﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <p></p>
    <script>
        function time(){
            var now = new Date();
            return ''
            + (now.getHours() >= 10 ? now.getHours() : '0' +  now.getHours()) + ':'
            + (now.getMinutes() >= 10 ? now.getMinutes() : '0' + now.getMinutes()) + ':'
            + (now.getSeconds() >= 10 ? now.getSeconds() : '0' + now.getSeconds()) + ' '
            + (now.getMonth() + 1 >= 10 ? now.getMonth() + 1 : '0'  + (now.getMonth() + 1)) + '/'
            + (now.getDate() >= 10 ? now.getDate() : '0' + now.getDate()) + ' '
            + date() + ' '
            + now.getFullYear();
            function date(){
                switch(new Date().getDay()){
                    case 0 : return '星期日';
                    case 1 : return '星期一';
                    case 2 : return '星期二';
                    case 3 : return '星期三';
                    case 4 : return '星期四';
                    case 5 : return '星期五';
                    case 6 : return '星期六';
                }
            }
        }
        var p = document.querySelector('p');
            p.innerHTML = time();
        setInterval(function(){
            p.innerHTML = time();
        },1000);

    </script>
</body>
</html>